package com.atguigu02.singleton;

/**
* ClassName: GirlFriendTest
* Package: com.atguigu01.singleton
* Description:
* @Author ZY
* @Create  17:12
* @Version 1.0
*/public class GirlFriendTest {

    public static void main(String[] args) {


    }

}

//懒汉式
class GirlFriend{

    //1.类的构造器私有化
    private GirlFriend(){

    }

    //2.声明当前类的实例
    //4.次属性必须声明为static的
    private static GirlFriend instance = null;

    //3.通过getXxx()方法返回当前类的实例,如果为创建对象，则在方法内部进行创建
    public static GirlFriend getInstance(){
        if(instance == null){
            instance = new GirlFriend();
        }
        return instance;
    }


}
